import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:fluttermarketingplus/navigator/navigator_index.dart';

//闪屏页
class SplashPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _SplashPageState();
  }
}

class _SplashPageState extends State<SplashPage> {
  @override
  Widget build(BuildContext context) {
    //填充整个屏幕
    return Image.asset(
      "images/splash2.png",
      fit: BoxFit.fill,
    );
  }

  @override
  void initState() {
    super.initState();
    countDown();
  }

// 倒计时
  void countDown() {
    var _duration = new Duration(seconds: 3);
    new Future.delayed(_duration, go2HomePage);
  }

  void go2HomePage() {
    //跳转页面之后，销毁当前页面
    Navigator.of(context).pushAndRemoveUntil(
        new MaterialPageRoute(builder: (context) => NavigatorIndex()),
        (route) => route == null);
  }
}
